
library(SCP)
# 修改函数代码
new_get_legend <- function(plot) {
  plot <- cowplot::as_gtable(plot)
  grob_names <- plot$layout$name
  grobs <- plot$grobs
  grobIndex <- which(grepl("guide-box-bottom", grob_names)) # guide-box 改为 guide-box-bottom
  grobIndex <- grobIndex[1]
  matched_grobs <- grobs[[grobIndex]]
  return(matched_grobs)
}

# 使用 assignInNamespace() 赋值
assignInNamespace("get_legend", new_get_legend, ns = "SCP")

